//
//  StrategyDoubleParameter.m
//  StrategyInspector
//
//  Created by jiro on 12/07/29.
//  Copyright 2012 jiro music. All rights reserved.
//

#import "StrategyDoubleParameter.h"

StrategyDoubleParameter::StrategyDoubleParameter()
{
	type = StrategyParameter::Type_Double;
	currentValue = 0;
	startValue = 0;
	endValue = 0;
	interval = 0;
}

StrategyDoubleParameter::StrategyDoubleParameter( double value )
{
	type = StrategyParameter::Type_Double;
	currentValue = value;
	startValue = value;
	endValue = value;
	interval = 0;
}

StrategyDoubleParameter::StrategyDoubleParameter( double startValueArg, double endValueArg, double intervalArg )
{
	type = StrategyParameter::Type_Double;
	currentValue = startValueArg;
	startValue = startValueArg;
	endValue = endValueArg;
	interval = intervalArg;
}

bool StrategyDoubleParameter::isMutable() const
{
	if ( interval == 0 )
	{
		return true;
	}
	return false;
}

void StrategyDoubleParameter::nextValue( bool& isLast )
{
	currentValue += interval;
	if ( currentValue > endValue )
	{
		isLast = true;
	}
	else
	{
		isLast = false;
	}
}

void StrategyDoubleParameter::initialize()
{
	currentValue = startValue;
}

double StrategyDoubleParameter::getDoubleValue() const
{
	return currentValue;
}

double StrategyDoubleParameter::getDoubleValueStart() const
{
	return startValue;
}

double StrategyDoubleParameter::getDoubleValueEnd() const
{
	return endValue;
}

void StrategyDoubleParameter::setDoubleValue( double value )
{
	currentValue = value;
}

StrategyParameter* StrategyDoubleParameter::copy() const
{
	StrategyDoubleParameter* p = new StrategyDoubleParameter( startValue, endValue, interval );
	return p;
}

void StrategyDoubleParameter::setValueMiddle()
{
	currentValue = ( endValue + startValue ) / 2.0;
}
